<template>
	<NavBar :obj="{ title: '售后详情', color: '#000', backgroundColor: 'transparent' }" :scrollTop="scrollTop" />

	<image src="/static/bg/bg_tuikxqtop.png" mode="widthFix" class="img-top"></image>

	<view class="fill">
		<view class="flex items-center justify-between">
			<view class="status flex flex-col justify-between">
				<view class="status_text">{{ info.status_text }}</view>
				<view class="status_desc">{{ info.status_desc }}</view>
			</view>
			<view class="up-ess" v-if="info.status == 2" @click="goUrl('/pages/refund/up-express?id=' + info.id)">上传物流</view>
		</view>
		<view class="infos">
			<!-- <view class="step flex items-center justify-center">
				
				<block v-if="info.type == 1">
					<up-steps :current="info.status" activeColor="#FB3204">
						<up-steps-item title="提交申请"></up-steps-item>
						<up-steps-item title="待审核"></up-steps-item>

						<up-steps-item title="退款成功" v-if="info.status != 5"></up-steps-item>
						<up-steps-item title="未通过" v-if="info.status == 5"></up-steps-item>
					</up-steps>
				</block>
				<block v-else>
					<up-steps :current="info.status" activeColor="#FB3204">
						<up-steps-item title="提交申请"></up-steps-item>
						<up-steps-item title="待审核"></up-steps-item>
						<up-steps-item title="待寄回"></up-steps-item>
						<up-steps-item title="待确认"></up-steps-item>
						<up-steps-item title="退款成功" v-if="info.status != 5"></up-steps-item>
						<up-steps-item title="未通过" v-if="info.status == 5"></up-steps-item>
					</up-steps>
				</block>
			</view> -->

			<view class="layout">
				<view class="item flex items-center justify-between">
					<view class="title big-title">退款总金额</view>
					<view class="val theme-color rmb">{{ info.total }}</view>
				</view>
				<view class="item flex items-center justify-between">
					<view class="title">商品金额</view>
					<view class="val rmb-black">{{ info.product_total }}</view>
				</view>
				<view class="item flex items-center justify-between">
					<view class="title">运费</view>
					<view class="val rmb-black">{{ info.order_freight }}</view>
				</view>
				<view class="item flex items-center justify-between">
					<view class="title">商品件数</view>
					<view class="val">{{ info.product?.length }}</view>
				</view>
			</view>

			<view class="product">
				<view class="big-title">退款/退货商品</view>
				<view class="item flex" v-for="(item, index) in info.product" :key="index">
					<image :src="item.icon" class="icon"></image>
					<view class="info flex justify-between flex-1">
						<view class="top flex-1">
							<view class="title line-2-clamp">{{ item.title }}</view>
							<view class="spec">{{ item.spec }}</view>
						</view>
						<view class="total flex flex-col items-center justify-center">
							<view class="val flex items-center">
								<view class="tips">退款</view>
								<view class="rmb-black">{{ item.vip_price }}</view>
							</view>
							<view class="num">共{{ item.num }}件</view>
						</view>
					</view>
				</view>
			</view>

			<view class="layout mt-30">
				<view class="item flex items-center justify-between">
					<view class="title big-title">退款信息</view>
				</view>
				<view class="item flex items-center justify-between">
					<view class="title">退款编号</view>
					<view class="val gray">
						<text>{{ info.sn }}</text>
						<text class="copy">复制</text>
					</view>
				</view>
				<view class="item flex items-center justify-between">
					<view class="title">退款方式</view>
					<view class="val">{{ info.pay_way }}</view>
				</view>
				<view class="item flex items-center justify-between">
					<view class="title">退款原因</view>
					<view class="val">{{ info.reason }}</view>
				</view>
				<view class="item flex items-center justify-between">
					<view class="title">申请时间</view>
					<view class="val">{{ info.create_time }}</view>
				</view>
			
			</view>

			<view class="layout mt-30">
				<view class="item flex items-center justify-between">
					<view class="title big-title">退款说明</view>
				</view>
				<view class="describe">
					{{ info.describe }}
				</view>
				<view class="images" v-if="info.images?.length > 0">
					<up-row gutter="10" customStyle="flex-wrap: wrap;">
						<up-col span="3" v-for="(item, index) in info.images" :key="index" style="margin-bottom: 10rpx">
							<image :src="item" class="icon"></image>
						</up-col>
					</up-row>
				</view>
			</view>
			
			<view class="layout mt-30" v-if="info.reject_msg">
				<view class="item flex items-center justify-between">
					<view class="title big-title">未通过原因</view>
				</view>
				<view class="describe" style="color: red;">
					{{ info.reject_msg }}
				</view>
			
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref, nextTick } from 'vue';
	import { onLoad, onShow, onPageScroll } from '@dcloudio/uni-app';

	import { port, hint, goUrl, loading, closeLoading } from '/service/port';
	import { goBack } from '../../service/port';
	const timeData = ref({});
	const onChange = (e) => {
		timeData.value = e;
	};

	const id = ref('');
	const info = ref({});
	const scrollTop = ref(0);
	onPageScroll((e) => {
		scrollTop.value = e.scrollTop;
	});

	onLoad((e) => {
		if (e.id) {
			id.value = e.id;
		}
	});

	onShow(() => {
		getMyRefundOrderInfo();
	});

	function editOrder(id, type) {
		uni.showModal({
			title: '请确认',
			content: type == 'cancel' ? '确定要取消订单吗？' : '是否确认收货？',
			confirmColor: '#FB3204',
			success: async function (res) {
				if (res.confirm) {
					loading();
					let res = await port('editOrder', { id: id, type: type });
					await nextTick();
					hint(res.msg);
					closeLoading();
					if (type == 'cancel') {
						goBack();
					} else {
						getMyRefundOrderInfo();
					}
				}
			}
		});
	}

	async function getMyRefundOrderInfo() {
		let res = await port('getMyRefundOrderInfo', { id: id.value });
		info.value = res.data;
	}
</script>

<style scoped lang="scss">
	:global(page) {
		background-color: #f4f5f8;
	}

	.img-top {
		width: 100%;
		height: 530rpx;
		position: absolute;
		top: 0;
		left: 0;
		z-index: 0;
	}
	.up-ess {
		font-weight: 400;
		font-size: 26rpx;
		color: #fb3204;
		border-radius: 16rpx;
		border: 1px solid #fb3204;
		padding: 10rpx 25rpx;
	}

	.layout {
		background: #ffffff;
		border-radius: 20rpx;
		padding: 30rpx;
		margin-bottom: 24rpx;
		.total-item {
			border-top: 1rpx solid #eeeeee;
		}
		.describe {
			font-weight: 400;
			font-size: 24rpx;
			color: #666666;
		}
		.images {
			margin-top: 24rpx;
			.icon {
				width: 156rpx;
				height: 156rpx;
				border-radius: 18rpx;
			}
		}

		.item {
			padding-bottom: 30rpx;

			&:last-child {
				padding-bottom: 0;
			}
			.title {
				font-weight: 400;
				font-size: 26rpx;
				color: #333333;
				> text {
					font-weight: 400;
					font-size: 22rpx;
					color: #888888;
				}
			}

			.big-title {
				font-weight: 500;
				font-size: 28rpx;
				color: #000000;
			}

			.val {
				font-weight: 400;
				font-size: 24rpx;
				color: #000000;
			}

			.theme-color {
				color: #fb3204;
			}

			.copy {
				color: #000;
				&:before {
					content: '|';
					color: #eeeeee;
					margin: 0 10rpx;
				}
			}
			.gray {
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
			}
			.total {
				padding-top: 30rpx;
				.text {
					font-weight: 400;
					font-size: 24rpx;
					color: #000000;
					margin-bottom: 5rpx;
				}
				.text-val {
					font-size: 34rpx;
					color: #fb3204;
				}
				.rmb:before {
					font-size: 28rpx;
				}
			}
		}
	}

	.fill {
		position: relative;
		margin: 30rpx;
		padding-bottom: 120rpx;
		.status {
			margin-left: 2rpx;
			.status_text {
				font-weight: 500;
				font-size: 34rpx;
				color: #000000;
			}
			.status_desc {
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
			}
		}
		.infos {
			border-radius: 30rpx 30rpx 0rpx 0rpx;
			margin-top: 40rpx;
			.step {
				padding: 20rpx 0;
				background: #ffdfd8;
				border-radius: 20rpx 20rpx 0rpx 0rpx;
				margin-bottom: -10rpx;

				.steps-item {
					> text {
						font-weight: 400;
						font-size: 24rpx;
						color: #000000;
						margin-left: 5rpx;
					}
				}
				.next {
					margin: 5rpx;
				}
				.gray {
					> text {
						color: #888888;
					}
				}
			}

			.address {
				background: #ffffff;
				border-radius: 20rpx;
				padding: 25rpx;

				.null-address {
					font-weight: 500;
					font-size: 30rpx;
					color: #000000;
					padding: 20rpx 0;
				}

				.province {
					.val {
						font-weight: 400;
						font-size: 24rpx;
						color: #333333;
						margin-left: 14rpx;
					}
					.icon {
						width: 27rpx;
						height: 27rpx;
					}
				}
				.details {
					font-weight: 500;
					font-size: 30rpx;
					color: #000000;
					margin: 18rpx 0;
				}
				.nickname {
					.val {
						font-weight: 400;
						font-size: 24rpx;
						color: #333333;
					}
					.mobile {
						font-weight: 400;
						font-size: 24rpx;
						color: #333333;
						margin-left: 31rpx;
						margin-top: 2rpx;
					}
				}
				.right-icon {
					font-weight: 400;
					font-size: 26rpx;
					color: #666666;
					border-radius: 10rpx;
					border: 1px solid #cccccc;
					padding: 10rpx 20rpx;
					margin-left: 59rpx;
				}
			}

			.product {
				background: #ffffff;
				border-radius: 20rpx;
				padding: 0 24rpx;
				margin-top: 24rpx;
				.big-title {
					font-weight: 500;
					font-size: 28rpx;
					color: #000000;
					padding-top: 20rpx;
				}

				.item {
					padding: 24rpx 0;
					border-bottom: 1rpx solid #eeeeee;
					&:last-child {
						border-bottom: none;
					}
					.icon {
						width: 142rpx;
						height: 142rpx;
						border-radius: 20rpx;
					}
					.info {
						margin-left: 23rpx;
						.top {
							.title {
								font-weight: 400;
								font-size: 26rpx;
								color: #000000;
							}
							.spec {
								font-weight: 400;
								font-size: 22rpx;
								color: #999999;
								margin-top: 15rpx;
							}
						}
						.total {
							margin-left: 10rpx;
							.val {
								font-weight: 500;
								font-size: 30upx;
								color: #000000;
							}
							.tips {
								font-weight: 400;
								font-size: 22upx;
							}
							.num {
								font-weight: 400;
								font-size: 24upx;
								color: #333333;
								margin-top: 10upx;
								margin-left: 15px;
							}
						}
					}
				}
			}
		}
	}
</style>
